
#request 包含所有前端请求数据


from flask import Flask,render_template,request
app = Flask(__name__)

@app.route('/index',methods=['GET','POST'])
def index():
    if request.method == 'GET':
        print('get')
        #return 'get'
        return render_template('index.html')
    if request.method == 'POST':
        name = request.form.get('name')
        passwd = request.form.get('password')
        print(name,passwd)

        #发送post请求 json参数直接为一个字典数据
        a = {"mobilephone": "18611000001", "pwd": "xxxxxxxxxxxx"}
        url = "http://XXXXXXXX"
        headers = {'Content-Type': 'application/json;charset=UTF-8'}
        res = request.request("post", url, json=a, headers=headers)

        return 'post'
        #return render_template('index.html')

if __name__ == '__main__':
    app.run()
